#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ctrlsys_comercial.settings")
    
    from django.contrib.sites.models import *
    site = Site.objects.all()[0]
    site.name = u'localhost'
    
    from django.contrib.auth.models import *
    
    gerente = Group.objects.get(name = 'Gerente')
    operador = Group.objects.get(name = 'Operador')
    vendedor = Group.objects.get(name = 'Vendedor')
    cpd = Group.objects.get(name = 'CPD')
    
    # lista de permissoes
    lista = [
        (u'admin', u'Can add log entry'),
        (u'admin', u'Can change log entry'),
        (u'admin', u'Can delete log entry'),
        (u'auth', u'Can add group'),
        (u'auth', u'Can change group'),
        (u'auth', u'Can delete group'),
        (u'auth', u'Can add permission'),
        (u'auth', u'Can change permission'),
        (u'auth', u'Can delete permission'),
        (u'auth', u'Can add user'),
        (u'auth', u'Can change user'),
        (u'auth', u'Can delete user'),
        (u'cliente', u'Can add Cartão de Crédito'),
        (u'cliente', u'Can change Cartão de Crédito'),
        (u'cliente', u'Can delete Cartão de Crédito'),
        (u'cliente', u'Can add cliente'),
        (u'cliente', u'Can change cliente'),
        (u'cliente', u'Can delete cliente'),
        (u'cliente', u'Can add email'),
        (u'cliente', u'Can change email'),
        (u'cliente', u'Can delete email'),
        (u'cliente', u'Can add endereco'),
        (u'cliente', u'Can change endereco'),
        (u'cliente', u'Can delete endereco'),
        (u'cliente', u'Can add telefone'),
        (u'cliente', u'Can change telefone'),
        (u'cliente', u'Can delete telefone'),
        (u'configuracao', u'Can add dados'),
        (u'configuracao', u'Can change dados'),
        (u'configuracao', u'Can delete dados'),
        (u'contenttypes', u'Can add content type'),
        (u'contenttypes', u'Can change content type'),
        (u'contenttypes', u'Can delete content type'),
        (u'django_evolution', u'Can add evolution'),
        (u'django_evolution', u'Can change evolution'),
        (u'django_evolution', u'Can delete evolution'),
        (u'django_evolution', u'Can add version'),
        (u'django_evolution', u'Can change version'),
        (u'django_evolution', u'Can delete version'),
        (u'estoque', u'Can add categoria'),
        (u'estoque', u'Can change categoria'),
        (u'estoque', u'Can delete categoria'),
        (u'estoque', u'Can add produto'),
        (u'estoque', u'Can change produto'),
        (u'estoque', u'Can delete produto'),
        (u'estoque', u'Pode visualizar produtos'),
        (u'estoque', u'Pode adicionar valor'),
        (u'estoque', u'Can add setor'),
        (u'estoque', u'Can change setor'),
        (u'estoque', u'Can delete setor'),
        (u'financeiro', u'Can add cheque'),
        (u'financeiro', u'Can change cheque'),
        (u'financeiro', u'Can delete cheque'),
        (u'financeiro', u'Can add Compra parcelada'),
        (u'financeiro', u'Can change Compra parcelada'),
        (u'financeiro', u'Can delete Compra parcelada'),
        (u'financeiro', u'Can add Pagamento a receber'),
        (u'financeiro', u'Can change Pagamento a receber'),
        (u'financeiro', u'Can delete Pagamento a receber'),
        (u'financeiro', u'Pode visualizar pagamentos a receber'),
        (u'fornecedor', u'Can add email'),
        (u'fornecedor', u'Can change email'),
        (u'fornecedor', u'Can delete email'),
        (u'fornecedor', u'Can add endereco'),
        (u'fornecedor', u'Can change endereco'),
        (u'fornecedor', u'Can delete endereco'),
        (u'fornecedor', u'Can add fornecedor'),
        (u'fornecedor', u'Can change fornecedor'),
        (u'fornecedor', u'Can delete fornecedor'),
        (u'fornecedor', u'Can add telefone'),
        (u'fornecedor', u'Can change telefone'),
        (u'fornecedor', u'Can delete telefone'),
        (u'fornecedor', u'Can add transportadora'),
        (u'fornecedor', u'Can change transportadora'),
        (u'fornecedor', u'Can delete transportadora'),
        (u'impressao', u'Can add impressora'),
        (u'impressao', u'Can change impressora'),
        (u'impressao', u'Can delete impressora'),
        (u'registro', u'Can add evento'),
        (u'registro', u'Can change evento'),
        (u'registro', u'Can delete evento'),
        (u'relatorio', u'Can add relatorio'),
        (u'relatorio', u'Can change relatorio'),
        (u'relatorio', u'Can delete relatorio'),
        (u'relatorio', u'Pode visualizar relatório'),
        (u'sessions', u'Can add session'),
        (u'sessions', u'Can change session'),
        (u'sessions', u'Can delete session'),
        (u'sites', u'Can add site'),
        (u'sites', u'Can change site'),
        (u'sites', u'Can delete site'),
        (u'venda', u'Pode abrir um caixa'),
        (u'venda', u'Can add caixa'),
        (u'venda', u'Pode alterar um caixa'),
        (u'venda', u'Can change caixa'),
        (u'venda', u'Can delete caixa'),
        (u'venda', u'Pode visualizar Caixa'),
        (u'venda', u'Can add devolucao'),
        (u'venda', u'Can change devolucao'),
        (u'venda', u'Can delete devolucao'),
        (u'venda', u'Pode fazer devolução'),
        (u'venda', u'Pode fazer devolução'),
        (u'venda', u'Can add entrada'),
        (u'venda', u'Pode adicionar Entradas'),
        (u'venda', u'Can change entrada'),
        (u'venda', u'Can delete entrada'),
        (u'venda', u'Pode esconder Entradas'),
        (u'venda', u'Pode visualizar Entradas'),
        (u'venda', u'Can add Guichê'),
        (u'venda', u'Can change Guichê'),
        (u'venda', u'Can delete Guichê'),
        (u'venda', u'Can add item'),
        (u'venda', u'Can change item'),
        (u'venda', u'Can delete item'),
        (u'venda', u'Can add Pagamento parcial'),
        (u'venda', u'Can change Pagamento parcial'),
        (u'venda', u'Can delete Pagamento parcial'),
        (u'venda', u'Can add pedido'),
        (u'venda', u'Pode alterar um pedido'),
        (u'venda', u'Can change pedido'),
        (u'venda', u'Pode dar descontos'),
        (u'venda', u'Can delete pedido'),
        (u'venda', u'Pode criar um novo pedido'),
        (u'venda', u'Can add saida'),
        (u'venda', u'Pode adicionar Saídas'),
        (u'venda', u'Can change saida'),
        (u'venda', u'Can delete saida'),
        (u'venda', u'Pode esconder Saídas'),
        (u'venda', u'Pode visualizar Saídas'),
    ]
    # fim
    
    # lista Gerente
    lista = [
        (u'admin', u'Can add log entry'),
        (u'auth', u'Can add user'),
        (u'auth', u'Can change user'),
        (u'registro', u'Can change evento'),
        (u'relatorio', u'Pode visualizar relatório'),
        
    ]
    
    for i in lista:
        gerente.permissions.add(Permission.objects.get(content_type__app_label = i[0], name = i[1]).id)
    
    # lista Operador
    lista = [
        (u'cliente', u'Can add cliente'),
        (u'cliente', u'Can change cliente'),
        (u'cliente', u'Can add email'),
        (u'cliente', u'Can change email'),
        (u'cliente', u'Can delete email'),
        (u'cliente', u'Can add endereco'),
        (u'cliente', u'Can change endereco'),
        (u'cliente', u'Can delete endereco'),
        (u'cliente', u'Can add telefone'),
        (u'cliente', u'Can change telefone'),
        (u'cliente', u'Can delete telefone'),
        (u'estoque', u'Can add categoria'),
        (u'estoque', u'Can change categoria'),
        (u'estoque', u'Can delete categoria'),
        (u'estoque', u'Can add produto'),
        (u'estoque', u'Can change produto'),
        (u'estoque', u'Pode visualizar produtos'),
        (u'estoque', u'Can add setor'),
        (u'estoque', u'Can change setor'),
        (u'estoque', u'Can delete setor'),
        (u'financeiro', u'Can add cheque'),
        (u'financeiro', u'Can change cheque'),
        (u'financeiro', u'Can delete cheque'),
        (u'financeiro', u'Can add Compra parcelada'),
        (u'financeiro', u'Can change Compra parcelada'),
        (u'financeiro', u'Can delete Compra parcelada'),
        (u'financeiro', u'Can add Pagamento a receber'),
        (u'financeiro', u'Can change Pagamento a receber'),
        (u'financeiro', u'Can delete Pagamento a receber'),
        (u'financeiro', u'Pode visualizar pagamentos a receber'),
        (u'fornecedor', u'Can add email'),
        (u'fornecedor', u'Can change email'),
        (u'fornecedor', u'Can delete email'),
        (u'fornecedor', u'Can add endereco'),
        (u'fornecedor', u'Can change endereco'),
        (u'fornecedor', u'Can delete endereco'),
        (u'fornecedor', u'Can add fornecedor'),
        (u'fornecedor', u'Can change fornecedor'),
        (u'fornecedor', u'Can add telefone'),
        (u'fornecedor', u'Can change telefone'),
        (u'fornecedor', u'Can delete telefone'),
        (u'fornecedor', u'Can add transportadora'),
        (u'fornecedor', u'Can change transportadora'),
        (u'fornecedor', u'Can delete transportadora'),
        (u'venda', u'Pode abrir um caixa'),
        (u'venda', u'Pode alterar um caixa'),
        (u'venda', u'Pode visualizar Caixa'),
        (u'venda', u'Pode fazer devolução'),
        (u'venda', u'Pode adicionar Entradas'),
        (u'venda', u'Pode esconder Entradas'),
        (u'venda', u'Pode visualizar Entradas'),
        (u'venda', u'Can add item'),
        (u'venda', u'Can change item'),
        (u'venda', u'Can delete item'),
        (u'venda', u'Can add Pagamento parcial'),
        (u'venda', u'Can change Pagamento parcial'),
        (u'venda', u'Can delete Pagamento parcial'),
        (u'venda', u'Pode alterar um pedido'),
        (u'venda', u'Pode dar descontos'),
        (u'venda', u'Pode criar um novo pedido'),
        (u'venda', u'Pode adicionar Saídas'),
        (u'venda', u'Pode esconder Saídas'),
        (u'venda', u'Pode visualizar Saídas'),
    ]
    
    for i in lista:
        operador.permissions.add(Permission.objects.get(content_type__app_label = i[0], name = i[1]).id)
    
    # lista Vendedor
    lista = [
        
    ]
    
    for i in lista:
        vendedor.permissions.add(Permission.objects.get(content_type__app_label = i[0], name = i[1]).id)
    
    # lista CPD
    lista = [
        (u'admin', u'Can add log entry'),
        (u'auth', u'Can add group'),
        (u'auth', u'Can change group'),
        (u'auth', u'Can delete group'),
        (u'auth', u'Can add user'),
        (u'auth', u'Can change user'),
        (u'cliente', u'Can add cliente'),
        (u'cliente', u'Can change cliente'),
        (u'cliente', u'Can add email'),
        (u'cliente', u'Can change email'),
        (u'cliente', u'Can delete email'),
        (u'cliente', u'Can add endereco'),
        (u'cliente', u'Can change endereco'),
        (u'cliente', u'Can delete endereco'),
        (u'cliente', u'Can add telefone'),
        (u'cliente', u'Can change telefone'),
        (u'cliente', u'Can delete telefone'),
        (u'configuracao', u'Can change dados'),
        (u'estoque', u'Can add categoria'),
        (u'estoque', u'Can change categoria'),
        (u'estoque', u'Can delete categoria'),
        (u'estoque', u'Can add produto'),
        (u'estoque', u'Can change produto'),
        (u'estoque', u'Can delete produto'),
        (u'estoque', u'Pode visualizar produtos'),
        (u'estoque', u'Pode adicionar valor'),
        (u'estoque', u'Can add setor'),
        (u'estoque', u'Can change setor'),
        (u'estoque', u'Can delete setor'),
        (u'financeiro', u'Can change cheque'),
        (u'financeiro', u'Can delete cheque'),
        (u'financeiro', u'Can change Compra parcelada'),
        (u'financeiro', u'Can delete Compra parcelada'),
        (u'financeiro', u'Can change Pagamento a receber'),
        (u'financeiro', u'Can delete Pagamento a receber'),
        (u'financeiro', u'Pode visualizar pagamentos a receber'),
        (u'fornecedor', u'Can add email'),
        (u'fornecedor', u'Can change email'),
        (u'fornecedor', u'Can delete email'),
        (u'fornecedor', u'Can add endereco'),
        (u'fornecedor', u'Can change endereco'),
        (u'fornecedor', u'Can delete endereco'),
        (u'fornecedor', u'Can add fornecedor'),
        (u'fornecedor', u'Can change fornecedor'),
        (u'fornecedor', u'Can add telefone'),
        (u'fornecedor', u'Can change telefone'),
        (u'fornecedor', u'Can delete telefone'),
        (u'fornecedor', u'Can add transportadora'),
        (u'fornecedor', u'Can change transportadora'),
        (u'fornecedor', u'Can delete transportadora'),
        (u'impressao', u'Can add impressora'),
        (u'impressao', u'Can change impressora'),
        (u'impressao', u'Can delete impressora'),
        (u'relatorio', u'Pode visualizar relatório'),
        (u'venda', u'Pode visualizar Caixa'),
        (u'venda', u'Pode fazer devolução'),
        (u'venda', u'Pode adicionar Entradas'),
        (u'venda', u'Pode esconder Entradas'),
        (u'venda', u'Pode visualizar Entradas'),
        (u'venda', u'Can add Guichê'),
        (u'venda', u'Can change Guichê'),
        (u'venda', u'Can delete Guichê'),
        (u'venda', u'Pode adicionar Saídas'),
        (u'venda', u'Pode esconder Saídas'),
        (u'venda', u'Pode visualizar Saídas'),
    ]
    
    for i in lista:
        cpd.permissions.add(Permission.objects.get(content_type__app_label = i[0], name = i[1]).id)
    
